package main.java.fireStrategy;

import main.java.Bullet;
import main.java.Dir;
import main.java.Tank;

public class FourDirectionStrategy implements FireStrategy{

    private FourDirectionStrategy(){}

    private static class FourDirectionStrategyHolder {
        private final static FireStrategy INSTANCE = new FourDirectionStrategy();
    }

    public static FireStrategy getInstance() {return FourDirectionStrategyHolder.INSTANCE;}

    @Override
    public void fire(Tank t) {
        int bX = t.getX() + Tank.WIDTH / 2 - Bullet.WIDTH / 2;
        int bY = t.getY() + Tank.HEIGHT / 2 - Bullet.HEIGHT / 2;
        for(int i = 0; i < 4; i++){
            new Bullet(bX, bY, Dir.values()[i], t.getGroup(), t.getTf());
        }
    }

}
